﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using mesoBoard.Data;
using mesoBoard.Data.Repositories;
using System.Web.Caching;
using System.Web.Mvc.Html;
using System.Data;

namespace mesoBoard.Common.HtmlHelpers
{
    public static partial class mesoBoardHtmlHelpers
    {
        public static string CreatePostLink(this HtmlHelper html, Thread TheThread)
        {
            string txt = TheThread.IsLocked ? "Locked" : "Create Post";
            string atClass = TheThread.IsLocked ? "img_link create-post-locked" : "img_link create-post";
            if(TheThread.IsLocked)
                return html.ActionLink(txt, "ViewThread", "Board", new { ThreadID = TheThread.ThreadID }, new { @class = atClass }).ToString();
            else
                return html.ActionLink(txt, "CreatePost", "Post", new { ThreadID = TheThread.ThreadID }, new { @class = atClass }).ToString();
        }

        public static string SubscriptionLink(this HtmlHelper html, int ThreadID, bool IsSubscribed)
        {
            string txt = IsSubscribed ? "Unsubscribe to Thread" : "Subscribe to Thread";
            string atClass  = "img_link thread-subscription";

            if(IsSubscribed)
                return html.ActionLink(txt, "UnsubscribeToThread", new { ThreadID = ThreadID }, new { @class = atClass }).ToString();
            else
                return html.ActionLink(txt, "SubscribeToThread", new { ThreadID = ThreadID }, new { @class = atClass }).ToString();
        }
    }
}
